package com.bonc.modules.home.controller;

import com.bonc.common.utils.Result;
import com.bonc.modules.home.param.SpecialActionParam;
import com.bonc.modules.home.result.ChartDataResult;
import com.bonc.modules.home.service.SpecialActionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author jinlong
 * @date 2021/8/23
 */
@RestController
@RequestMapping("/specialAction")
public class SpecialActionController {

    @Autowired
    private SpecialActionService specialActionService;

    @GetMapping("peakShavingChart")
    public Result getPeakShavingChart(@Validated(SpecialActionParam.peakShaving.class) SpecialActionParam specialActionParam) {
        ChartDataResult chart = specialActionService.getPeakShavingChart(specialActionParam);
        return Result.ok().put("data", chart);
    }

    @GetMapping("sunshineActionChart")
    public Result getSunshineActionChart(@Validated(SpecialActionParam.sunshineAction.class) SpecialActionParam specialActionParam) {
        Map<String, Object> chart = specialActionService.getSunshineActionMultipleChart(specialActionParam);
        return Result.ok().put("data", chart);
    }

}
